﻿using System.Linq;

namespace Hvam.SharePoint.Search.Language.Parsers
{
    internal class StringParser : CharParser
    {
        public static Parser<T> Return<T>(T value)
        {
            return i => new Success<T>(value, i);
        }

        public static Parser<string> String(string s)
        {
            return
                s.Select(Char)
                    .Aggregate(
                        Return(Enumerable.Empty<char>()),
                        (a, p) => a.Concat(p.Once())).Text();
        }
    }
}